package ntd.remote.link.bo;

import cn.hutool.json.JSONUtil;
import lj.netty.bean.LJNettyBo;
import lj.netty.bean.LJNettyMsgContext;
import lombok.Data;
import lombok.experimental.Accessors;
import ntd.remote.online.bo.OnlineInfo;

@Data
@Accessors(chain = true)
public class MsgBO {

    private String sourceCode;

    private String netCode;

    private String terminalCode;

    private String actionCode;

    private String data;

    private byte[] bytes;

    public static MsgBO transform(OnlineInfo onlineInfo) {
        MsgBO msgBO = new MsgBO();
        msgBO.setNetCode(onlineInfo.getNettyChannelCode());
        return msgBO;
    }

    public static MsgBO transform(LJNettyMsgContext ljNettyMsgContext) {
        MsgBO msgBO = ljNettyMsgContext.getData(MsgBO.class);
        msgBO.setNetCode(ljNettyMsgContext.getLJNettyBo().getNettyCode());
        msgBO.setBytes(ljNettyMsgContext.getLjProtocolInfo().getBytes());
        return msgBO;
    }
}
